// phalanx is_builtin_vector.hpp.cu header file

// Copyright (c) 2010 - 2011 Kohei Takahashi (Flast).
// Distributed under the MIT license. for more detail see COPYING.

#ifndef IG_PHALANX_TYPE_TRAITS_DETAIL_IS_BUILTIN_VECTOR_HPP_CU_ONCE_
#define IG_PHALANX_TYPE_TRAITS_DETAIL_IS_BUILTIN_VECTOR_HPP_CU_ONCE_

#include <phalanx/config.hpp.cu>

#include <vector_types.h>

#include <boost/preprocessor/repeat.hpp>
#include <boost/preprocessor/inc.hpp>
#include <boost/preprocessor/dec.hpp>

#include <phalanx/type_traits/integral_constant.hpp.cu>

namespace phalanx
{

namespace traits_detail
{

template < typename >
struct is_builtin_vector
  : public ::phalanx::false_type {};

#define IS_BUILTIN_VECTOR_IMPL( _unused_z, elnum, type_prefix ) \
  template <> \
  struct is_builtin_vector< BOOST_PP_CAT( type_prefix, BOOST_PP_INC( elnum ) ) > \
    : public ::phalanx::true_type {};

#define IS_BUILTIN_VECTOR_DEF( dim, type_prefix ) \
  BOOST_PP_REPEAT( dim, IS_BUILTIN_VECTOR_IMPL, type_prefix )

#define IS_BUILTIN_VECTOR_IMPL_I( dim, type_prefix ) \
  IS_BUILTIN_VECTOR_IMPL( 0, BOOST_PP_DEC( dim ), type_prefix )

#define IS_BUILTIN_VECTOR_IMPL_R( dim, type_prefix ) \
  IS_BUILTIN_VECTOR_DEF( dim, type_prefix )

#define IS_BUILTIN_VECTOR_IMPL_Z( dim, type_prefix ) \
  IS_BUILTIN_VECTOR_DEF( dim, type_prefix ); \
  IS_BUILTIN_VECTOR_DEF( dim, BOOST_PP_CAT( u, type_prefix ) )

IS_BUILTIN_VECTOR_IMPL_Z( 4,     char );
IS_BUILTIN_VECTOR_IMPL_Z( 4,    short );
IS_BUILTIN_VECTOR_IMPL_Z( 4,      int );
IS_BUILTIN_VECTOR_IMPL_Z( 4,     long );
IS_BUILTIN_VECTOR_IMPL_Z( 4, longlong );

IS_BUILTIN_VECTOR_IMPL_R( 4,  float );
IS_BUILTIN_VECTOR_IMPL_R( 4, double );

IS_BUILTIN_VECTOR_IMPL_I( 3, dim );

#undef IS_BUILTIN_VECTOR_IMPL_Z
#undef IS_BUILTIN_VECTOR_IMPL_R
#undef IS_BUILTIN_VECTOR_IMPL_I
#undef IS_BUILTIN_VECTOR_DEF
#undef IS_BUILTIN_VECTOR_IMPL

} // namespace traits_detail

} // namespace phalanx

#endif // IG_PHALANX_TYPE_TRAITS_DETAIL_IS_BUILTIN_VECTOR_HPP_CU_ONCE_

